<?php
// 本文档自动生成，仅供测试运行
class IndexAction extends BaseAction
{
    /**
    +----------------------------------------------------------
    * 默认操作
    +----------------------------------------------------------
    */
    public function index()
    {
		//房产资讯
		$news_zixu = M("news")->field("news.id,newstype.type_name,news.title,news.content,news.times,news_subtype.new_s_name")->join("newstype ON news.type = newstype.id")->join("news_subtype ON news.subtype = news_subtype.new_s_id")->where("newstype.type_name = '房产资讯'")->order("times desc,id desc")->limit("6")->select();
		$this->assign("news",$news_zixu);
		//时事新闻
		$news_shishi = M("news")->field("news.id,newstype.type_name,news.title,news.content,news.times,news_subtype.new_s_name")->join("newstype ON news.type = newstype.id")->join("news_subtype ON news.subtype = news_subtype.new_s_id")->where("newstype.type_name = '时事新闻'")->order("times desc,id desc")->limit("6")->select();
		$this->assign("news_shishi",$news_shishi);

		//区域
		$quyu = M("area")->select();
		$this->assign("quyu",$quyu);
		//商圈
		$district = M("district")->select();
		$this->assign("district",$district);
		
		//出租写字楼经纪人
		$broker = M("xiezilou")->join("vip ON xiezilou.x_broker = vip.v_id")->where("xiezilou.x_zulin=1 or xiezilou.x_zulin=2")->limit(6)->select();
		$this->assign("xrbroker",$broker);
	
		//商铺经纪人
		$sbroker = M("shangpu")->join("vip ON shangpu.s_broker = vip.v_id")->where("shangpu.s_zulin=1 or shangpu.s_zulin=2")->limit(6)->select();
		$this->assign("sbroker",$sbroker);

		//别墅经纪人
		$bbroker = M("bieshu")->join("vip ON bieshu.b_broker = vip.v_id")->where("bieshu.b_zulin=1 or bieshu.b_zulin=2")->limit(6)->select();
		$this->assign("bbroker",$bbroker);
		
		//写字楼出租
		$rent = M("xiezilou")->join("area ON xiezilou.x_quyu = area.a_id")->where("xiezilou.x_zulin=1")->limit(10)->select();
		foreach($rent as $key=>$value){
			if($i<4){
				$rents[] = $value;
				$i++;
			}
		}
	//	echo M("xiezilou")->getlastsql();
	//	var_dump($rent);exit;
		$this->assign("rents",$rents);
		$this->assign("rent",$rent);
		
		//写字楼出售
		$xsell = M("xiezilou")->join("area ON xiezilou.x_quyu = area.a_id")->where("xiezilou.x_zulin=2")->limit("10")->select();
		foreach($xsell as $key=>$value){
			if($s<4){
				$xsells[] = $value;
				$s++;
			}
		}
		$this->assign("sells",$xsells);
		$this->assign("sell",$xsell);
	//echo M("xiezilou")->getlastsql();
	//	var_dump($rent);exit;

		//精品写字楼
		$xjingpin = M("xiezilou")->join("area ON xiezilou.x_quyu = area.a_id")->join("rent ON rent.r_id = xiezilou.x_zulin")->limit("12")->where("is_jingpin=1")->select();
		$this->assign("xjingpin",$xjingpin);

	
		//商铺出租
		$srent = M("shangpu")->join("area ON shangpu.s_quyu = area.a_id")->where("shangpu.s_zulin=1")->limit("10")->select();
		foreach($srent as $key=>$value){
			if($t<4){
				$srents[] = $value;
				$t++;
			}
		}
	//	echo M("xiezilou")->getlastsql();
	//	var_dump($rent);exit;
		$this->assign("srents",$srents);
		$this->assign("srent",$srent);
		
		//商铺出售
		$ssell = M("shangpu")->join("area ON shangpu.s_quyu = area.a_id")->where("shangpu.s_zulin=2")->limit("10")->select();
		foreach($ssell as $key=>$value){
			if($q<4){
				$ssells[] = $value;
			}
		}
		$this->assign("ssells",$ssells);

		$this->assign("ssell",$ssell);
		//echo M("xiezilou")->getlastsql();
		//	var_dump($rent);exit;

		//精品商铺
		$sjingpin = M("shangpu")->join("area ON shangpu.s_quyu = area.a_id")->join("rent ON rent.r_id = shangpu.s_zulin")->where("is_jingpin=1")->limit("12")->select();

		$this->assign("sjingpin",$sjingpin);


		
		//别墅出售
		$bsell = M("bieshu")->join("area ON bieshu.b_quyu = area.a_id")->where("bieshu.b_zulin=2")->select();
		$this->assign("bsell",$bsell);
		//echo M("xiezilou")->getlastsql();
		//	var_dump($rent);exit;

		//精品别墅
		$bjingpin = M("bieshu")->select();
		$this->assign("bjingpin",$bjingpin);
		
		//品牌经纪公司
		$v_company = M("vip")->where("v_type=1")->limit("6")->select();
		$this->assign("v_company",$v_company);
		
		//创意装修
		$zhuangxiu = M("news")->join("newstype ON newstype.id = news.type")->where("newstype.type_name='创意装修'")->limit("10")->select();
		$this->assign("zhuangxiu",$zhuangxiu);

		//装修材料知识
		$cailiao = M("news")->join("newstype ON newstype.id = news.type")->join("news_subtype ON news_subtype.new_s_id = news.subtype")->where("newstype.type_name='装修材料知识'")->field("news.id,news.title,news_subtype.new_s_name")->limit("10")->select();
		$this->assign("cailiao",$cailiao);
		
		
		//求租
		$qiuzu = M("send")->where("types=3")->limit("9")->select();
		$this->assign("qiuzu",$qiuzu);

		//求购
		$qiugou = M("send")->where("types=4")->limit("9")->select();
		$this->assign("qiugou",$qiugou);
		//滚动图片
		$flash = M("advertising")->where("place=8")->order('id desc')->limit("5")->select();
		$this->assign("flash",$flash);
		
		//底部图片
		$lower = M("advertising")->where("place=7")->order('id desc')->limit('4')->select();
		$this->assign("lower",$lower);
		
		//底部图片
		$bottom = M("advertising")->where("place=7")->order('id desc')->limit('4')->select();
		$this->assign("bottom",$bottom);

        $this->display();


		
    }

    /**
    +----------------------------------------------------------
    * 探针模式
    +----------------------------------------------------------
    */
    public function checkEnv()
    {
        load('pointer',THINK_PATH.'/Tpl/Autoindex');//载入探针函数
        $env_table = check_env();//根据当前函数获取当前环境
        echo $env_table;
    }

}
?>